home *** CD-ROM | disk | FTP | other *** search
- #include "packets.h"
-
- main()
- {
- SetupMac();
- SetupMenu();
-
- InitThem();
-
- while ( DoLoop() );
- }
-
- SetupMac()
- {
- InitGraf(&thePort);
- InitFonts();
- InitWindows();
- InitDialogs(0L);
- InitMenus();
- TEInit();
- FlushEvents(everyEvent, 0);
- HiliteMenu(0);
-
- Stdio_MacInit(TRUE);
- printf("Packet Blaster Test v0.5\n");
-
- Click_On(FALSE);
- }
-
- MenuHandle myMenus[3];
-
- #define appleID 1
- #define testID 128
-
- SetupMenu()
- {
- if (GetResource('MENU', testID)==0) {
- SysBeep(20);
- return;
- }
-
- myMenus[0] = NewMenu( appleID, "\p\024" );
- AppendMenu(myMenus[0], "\pAbout this program...;(-");
-
- AddResMenu( myMenus[0], 'DRVR' );
- InsertMenu(myMenus[0], 0) ;
-
- myMenus[1] = GetMenu(testID);
- InsertMenu(myMenus[1], 0) ;
-
- DrawMenuBar();
- }
-
- int DoCommand( mResult )
- long mResult;
- {
- int theItem, temp;
- Str255 name;
- GrafPtr port;
-
- theItem = LoWord( mResult );
- switch (HiWord(mResult)) {
-
- case appleID:
- GetPort( &port );
- if (theItem == 1)
- DoAbout();
- else
- {
- GetItem(myMenus[0], theItem, &name);
- OpenDeskAcc( &name );
- }
- SetPort( port );
- break;
-
- case testID:
- switch (theItem)
- {
- case 1:
- Configure();
- break;
- case 2:
- SendThem();
- break;
- case 3:
- ReceiveThem();
- break;
- case 5:
- HiliteMenu(0);
- return 0;
- break;
- }
- break;
- }
-
- HiliteMenu(0);
- return(1);
- }
-
-
- DoLoop()
- {
- int where;
- EventRecord myEvent;
- WindowPtr whichWindow;
-
- SystemTask();
-
- if (GetNextEvent(everyEvent, &myEvent))
- {
- if ( !StdEvent( &myEvent ) )
- if (myEvent.what == mouseDown)
- {
- if ( where = FindWindow( myEvent.where, &whichWindow ) )
- {
- if (where == inMenuBar)
- return( DoCommand( MenuSelect(myEvent.where) ) );
-
- if (where == inSysWindow)
- SystemClick( &myEvent, whichWindow );
- }
- }
- else
- if (myEvent.what == keyDown)
- {
- register char theChar;
-
- theChar = myEvent.message & charCodeMask;
- if ((myEvent.modifiers & cmdKey) != 0)
- return( DoCommand( MenuKey( theChar ) ));
- }
- }
-
- return(1);
- }
-
- DoAbout()
- {
- WindowPtr w;
- Rect windRect;
- char version[40];
-
- /* make log window rect bottom */
- SetRect(&windRect, 50, 50, 410, 145);
-
- /* create log window */
- w = NewWindow( 0L, &windRect, "\pAbout Packets...", TRUE,
- altDBoxProc, (WindowPtr)-1, TRUE, 0L );
- SetPort(w);
-
- TextFont(monaco);
- TextSize(9);
-
- sprintf(version, "Packets v0.5");
- CtoPstr(version);
-
- MoveTo(2, 10);
- DrawString(version);
- MoveTo(2, 20);
- DrawString("\pBrad Parker (brad@cayman.com)");
-
- MoveTo(2, 40);
- DrawString("\pDesiged to test packet throughput of appletalk");
- MoveTo(2, 55);
- DrawString("\prouters.");
-
- while (!Button());
-
- DisposeWindow(w);
- }